# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>

_name=StyLua
pkgname=stylua
pkgver=0.17.1
pkgrel=1
pkgdesc='Code formatter for Lua'
arch=('loong64' 'x86_64')
url=https://github.com/JohnnyMorganz/StyLua
license=('MPL2')
depends=('gcc-libs')
makedepends=('rust')
source=("$url/archive/v$pkgver/$_name-$pkgver.tar.gz")
b2sums=('c41aa72cd0e164fe66cdd7a2c5afb4c26239269c70975aa50b89528dcf174f06d4c709f7264f353efc72f2d65b14cd7fc0e8a62bec8dddea68187946315fd6ea')

prepare() {
  cd $_name-$pkgver
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd $_name-$pkgver
  cargo build --release --locked --offline --all-features
}

check() {
  cd $_name-$pkgver
  cargo test --locked --offline
  cargo test --locked --offline --features luau
  cargo test --locked --offline --features lua52
}

package() {
  cd $_name-$pkgver
  install -Dt "$pkgdir"/usr/bin target/release/$pkgname
}
